home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / c / c-tools-.000 / c-tools- / c-tools-0.4 / examples / tst / obscure.silly < prev    next >
Encoding:
Text File  |  1995-08-13  |  864 b   |  46 lines

  1. /* output of `obscure -s stripcr.c obscure.silly' */
  2.  
  3.  
  4. #include <string.h>
  5. #include <stdio.h>
  6.  
  7. #include <ctype.h>
  8. #include <assert.h>
  9.  
  10. int main(int foo, char **bar)
  11. {
  12.     FILE *baz = stdin, *quux = stdout;
  13.     int fred;
  14.  
  15.     if (foo > 1) {
  16.     if (!strcmp(bar[1], "-h") || foo > 3) {
  17.         fprintf(stderr, "\
  18. %s: remove carriage returns from input file\n\
  19. usage: %s [input] [[output]]\n", bar[0], bar[0]);
  20.         exit(0);
  21.     } else {
  22.         if (strcmp(bar[1], "-") != 0 &&
  23.         (baz = fopen(bar[1], "rb")) == NULL) {
  24.         fprintf(stderr, "%s: no such file\n", bar[1]);
  25.         exit(1);
  26.         }
  27.     }
  28.     if (foo == 3) {
  29.         if ((quux = fopen(bar[2], "wb")) == NULL) {
  30.         fprintf(stderr, "%s: cannot open output file\n", bar[2]);
  31.         exit(1);
  32.         }
  33.     }
  34.     }
  35.     while ((fred = fgetc(baz)) != EOF)
  36.     if (fred != 0x0d)
  37.         fputc(fred, quux);
  38.  
  39.     fclose(baz);
  40.     fclose(quux);
  41.  
  42.     return 0;
  43. }
  44.  
  45.  
  46.